<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>LC·灯控配置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${hostUrl}/static/layui/css/layui.css"  media="all">
    <script src="${hostUrl}/static/layui/layui.js"></script>
    <script src="${hostUrl}/static/layui/custom/js/dickov.js"></script>
    <script>
        layui.use('form', function(){
            var form = layui.form;
            var $ = layui.$;
            //监听提交
            form.on('submit(formDemo)', function(data){
                $.ajax({
                    type: 'post',
                    data: $('#lcForm').serialize(),
                    url: '${hostUrl}/device/requireUpdateLC',
                    cache:false,
                    dataType:'json',
                    success: function (resp) {
                        layer.msg( resp.msg );
                    }
                })
                // 返回false，则不跳转页面
                return false;
            });

            //某行全开或全关
            form.on('switch(checkRow)', function (data) {
                $('td[name="tdRow'+this.name + '"]').find("input").prop("checked",this.checked);
                form.render('checkbox','tdCB');
            });

        });
    </script>
</head>
<body>
<br/>
&nbsp;&nbsp;<label >当前设备：${device.deviceName}(${device.deviceId})</label>
<br/>
<form class="layui-form" id="lcForm">
<input type="hidden" name="devId" value="${device.deviceId}">
<table class="layui-table" lay-size="sm">
    <colgroup>
        <col width="50">
        <col width="400">
        <col width="200">
    </colgroup>
    <thead>
    <tr>
        <th>场景</th>
        <th>各场景开关</th>
        <th>其他操作</th>
    </tr>
    </thead>
    <tbody>
    <#list lcpb.sceneData as sceneData1>
            <tr >
                <td >
                    <#if sceneData1_index == 0>开机场景
                    <#else>场景${sceneData1_index}
                    </#if>
                </td>
                <td name = 'tdRow_${sceneData1_index}' >
                    <div class="layui-form layui-form-item" lay-size="=sm"  lay-filter="tdCB">
<#--                        <div class="layui-input-block">-->
                    <#list sceneData1 as sceneData2>
                        <#if sceneData2_index lt 6>
                            <input  type="checkbox"
                                    name="sceneData"
                                    title="开关${sceneData2_index+1}"
                                    value = "${sceneData1_index}_${sceneData2_index}"
                                    <#if sceneData2>checked</#if>

                                    >
                        </#if>
                    </#list>
<#--                    </div>-->
                    </div>
                </td>
                <td>
                    <input type="checkbox"
                           lay-skin="switch"
                           lay-text="全开|全关"
                           lay-filter="checkRow"
                           name="_${sceneData1_index}">
                </td>
        </tr>
    </#list>
    </tbody>
</table>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">确认修改</button>
        </div>
    </div>
</form>
</body>
</html>